﻿Public Class DaoMatkhau

    Public Shared Function KiemtraUsername(ByVal ten As String) As Integer
        Dim flag As Integer = 1
        Dim data As New DataProvider
        Dim table As DataTable = Nothing
        Dim query As String = "select * from TaiKhoan where Ten='" + ten + "'"
        table = data.ExecuteQuery(query)
        If table.Rows.Count = 0 Then
            flag = 0
        End If
        Return flag
    End Function
    Public Shared Function KiemtraPass(ByVal ten As String, ByVal pass As String) As Integer
        Dim flag As Integer = 1
        Dim data As New DataProvider
        Dim table As DataTable = Nothing
        Dim query As String = "select * from TaiKhoan where Ten='" + ten + "' and Pass='" + pass + "'"
        table = data.ExecuteQuery(query)
        If table.Rows.Count = 0 Then
            flag = 0
        End If
        Return flag
    End Function
    Public Shared Function KiemtraDangnhap(ByVal dto As DTO.DtoMatkhau, ByRef err As String) As Integer
        err = String.Empty
        Dim flag As Integer = 1
        If KiemtraUsername(dto.Ten) = 0 Then
            err = "ten dang nhap khong ton tai"
            flag = 0
        ElseIf KiemtraPass(dto.Ten, dto.Pass) = 0 Then
            err = "Sai password"
            flag = 0
        End If
        Return flag
    End Function

   
End Class
